#include "loginwidget.h"
#include "./ui_loginwidget.h"

LoginWidget::LoginWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::LoginWidget) {
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);
    movie = new QMovie(":/imgs/bg.gif", QByteArray(), this);
    QObject::connect(movie, &QMovie::frameChanged, [this](int frameNumber) {
        if (movie->loopCount() == 0 && frameNumber == movie->frameCount() - 1) {
            movie->stop();
        }
    });
    movie->setCacheMode(QMovie::CacheAll);
    movie->setSpeed(1000);
    ui->ProfileLbl->setMovie(movie);
    movie->start();
}

LoginWidget::~LoginWidget() {
    delete movie;
    delete ui;
}

void LoginWidget::on_isReadedRdBtn_clicked() {
    if(ui->isReadedRdBtn->isChecked()) {
        ui->loginBtn->setStyleSheet("background-color: rgb(0, 141, 235);");
        ui->loginBtn->setEnabled(true);
        ui->loginBtn->setCursor(Qt::PointingHandCursor);
    } else {
        ui->loginBtn->setStyleSheet("background-color: rgb(164, 214, 255);");
        ui->loginBtn->setEnabled(false);
        ui->loginBtn->setCursor(Qt::ArrowCursor);
    }
}


void LoginWidget::on_CloseTBtn_clicked() {
    this->close();
}

